/**
 * 后台主页js
 */
var mgr= {
	startEvent:function(){
		var winHeight=$(window).height();
		$('#contIfr').attr('height',winHeight-50);
		
		typeAndFlag=typeAndFlag.substring(1,typeAndFlag.length-1);
		var typeAndFlags=typeAndFlag.split(',');
		//控制一级菜单 
		for(var i=0;i<typeAndFlags.length;i++){
			var type=typeAndFlags[i].split(';')[0];
			var flag=typeAndFlags[i].split(';')[1];
			if(type==1){
				if(flag){
					$('#firstMenuUl li').each(function(idx,obj){
						if($(obj).attr('name')==flag){
							$(obj).css('display','');
							$(obj).next().css('display','');
						}
					});
				}
			}
		}
	},
	
	bindEvent:function(){
		$('#firstMenuUl li a').click(function(){
			var name=$(this).parent().attr('name');
			var url = 'common/CommonCtrl/getSecondMenu';
	    	var params = {
    			'firstMenu':name
    		};
    		var cb = function(data) {
    			if(data.resultCode==1){
    				var url=mgr.getUrl(data.result.secondMenu);
    				$('#contIfr').attr("src",url);
    			}
    		};
    		sendApiNoLoad(url, params, cb, 'POST');
		});
	},
	
	getUrl:function(name){
		var url='';
		if(name=="sysUser"){
			url=APP_ADDRESS+'mgr/sysMgr/sysUser.jsp';
		}if(name=="sysRole"){
			url=APP_ADDRESS+'mgr/sysMgr/sysRole.jsp';
		}if(name=="sysModule"){
			url=APP_ADDRESS+'mgr/sysMgr/sysModule.jsp';
		}if(name=="sysResource"){
			url=APP_ADDRESS+'mgr/sysMgr/sysResource.jsp';
		}else if(name=="department"){
			url=APP_ADDRESS+'mgr/department/department.jsp';
		}else if(name=="duties"){
			url=APP_ADDRESS+'mgr/department/duties.jsp';
		}else if(name=="employee"){
			url=APP_ADDRESS+'mgr/department/employee.jsp';
		}else if(name=="attendance"){
			url=APP_ADDRESS+'mgr/department/attendance.jsp';
		}else if(name=="building"){
			url=APP_ADDRESS+'mgr/product/building.jsp';
		}else if(name=="area"){
			url=APP_ADDRESS+'mgr/product/area.jsp';
		}else if(name=="banBasic"){
			url=APP_ADDRESS+'mgr/product/banBasic.jsp';
		}else if(name=="houseType"){
			url=APP_ADDRESS+'mgr/product/houseType.jsp';
		}else if(name=="banProduct"){
			url=APP_ADDRESS+'mgr/product/banProduct.jsp';
		}else if(name=="payWay"){
			url=APP_ADDRESS+'mgr/product/payWay.jsp';
		}else if(name=="payParameter"){
			url=APP_ADDRESS+'mgr/product/payParameter.jsp';
		}else if(name=="customer"){
			url=APP_ADDRESS+'mgr/customer/customer.jsp';
		}
		return url;
	},
		
	init : function() {
		mgr.startEvent();
		mgr.bindEvent();
	}
};

$(document).ready(function() {
	mgr.init();
});


